﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace P2P.Util
{
    public class HashUtil
    {
        /// <summary>
        /// 计算哈希值
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static BigInteger ComputeSHAHashBigInteger(string data) 
        {
            BigInteger bigInteger = new BigInteger(Encoding.UTF8.GetBytes(data));
            using (SHA1 sha1 = SHA1.Create()) 
            {
                //计算哈希值
                byte[] hashBytes = sha1.ComputeHash(bigInteger.ToByteArray());
                return new BigInteger(hashBytes);
            }
        }
    }
}
